#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QDate>
#include <QMainWindow>

#include "../server/Commands.hpp"

class QAction;
class QMenuBar;
class QStackedWidget;
class QTableView;
class QTreeView;
class QPushButton;
class QLineEdit;
class QDateEdit;
class QDate;

class LoginDialog;
class Client;

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *event);
    
private:
    void actionInit();
    void menuBarInit();
    void statusBarInit();
    void stackedWidgetInit();
    void findWidgetCreate();

    void settingsForNotAuthorised();
    void settingsForAdmin();
    void settingsForOperator();
    void settingsForRegistrator();



    QMenuBar        *m_menuBar;
    QMenu           *m_mainAction;
    QMenu           *m_operationAction;
    QMenu           *m_aboutAction;
    QAction         *m_loginAction;
    QAction         *m_logoutAction;
    QAction         *m_closeAction;
    QAction         *m_findAction;
    QAction         *m_statisticsAction;
    QAction         *m_aboutProgramAction;
    QAction         *m_aboutQtAction;
    QAction         *m_usersAction;

    QStackedWidget  *m_stackedWidget;
    QWidget         *m_findWidget;
    QDateEdit       *m_currentDateEdit;
    QLineEdit       *m_boardNumberLineEdit;
    QDateEdit       *m_startReleaseDateEdit;
    QDateEdit       *m_endReleaseDateEdit;
    QPushButton     *m_byNextMonthFindButton;
    QPushButton     *m_byBoardNumFindButton;
    QPushButton     *m_byReleasePeriodFindButton;
    QTableView      *m_transportTableView;
    QTreeView       *m_statisticsTreeView;
    QTableView      *m_usersTableView;

    QThread         *m_networkThread;
    Client          *m_client;

    QString         m_name;
    QString         m_password;

private slots:
    void aboutProgram();
    void loginWindowShow();
    void logout();
    void errorDisplay(QString error);
    void connected();
    void settings(quint16 userRight);
    void findWidgetShow();
    void usersWidgetShow();
    void statisticsWidgetShow();
    void setMinimumDate(QDate minDate);
    void setMaximumDate(QDate maxDate);

    void searchOnNextMonthClicked();

signals:
    void connectToHost(QString hostIP, quint16 port);
    void authorization(QString name, QString password);
    void searchOnNextMonth(QDate );
};

#endif // MAINWINDOW_H
